var batteryTypeData = [];

$(document).ready(function() {
	showLoading();
	$('title', parent.document).html($('title').text());
	setBaseUrl();
	addTitle("batteryTypeUpdate");
	search();
})

function allClick(tabFlag){
	$(".comBody").hide();
	$("#" + tabFlag).show();
}
function search(){
	$('#BatteryType').val($("#detailID", parent.document).val());
	$ajax('searchBatteryType', 'searchBatteryTypeUpdate', searchBatteryType);
	$("#detailID", parent.document).val("");
}
function searchBatteryType(data){
	batteryTypeData = data && data.batteryTypeList || [];
	createComBody("detailOneBody", batteryTypeTable, batteryTypeData[0], 1);
	createComBody("detailTwoBody", batteryTypeTable, batteryTypeData[0], 2);
	$("#batteryType").attr("readonly", true);
	selectDate("batteryDateDate", 0);
	$('#confirm').show();
	if(batteryTypeData[0].enabled == true){
		$("#enabled").val(1);
	}else{
		$("#enabled").val(0);
	}
}
function updateBatteryType(data){
     var result = data && data.result;
     if (result == "Success"){
    	 showMessge(messageContent["Update.Success"], undefined, goback);
     } else if (result == "NotFound"){
    	 showMessge(messageContent["Update.Failed"]);
     } else if (result == "UserIDNoNull"){
         showMessge(messageContent["UserIDNoNull"]);
     } else{
    	 showMessge(messageContent["Update.Error"]);
     }
}
function confirm(){
	return checkForm("saveForm", batteryTypeTable);
}
function goback() {
	window.parent.skipMenu('vehicle/batteryType', 'drownDown3', '', 'carPage', 'batteryType');
}